package io.zhengsh.order.freemarker;

// import lombok.extern.slf4j.Slf4j;

import lombok.extern.slf4j.Slf4j;

import java.util.*;

@Slf4j
public class TestTemplate {

    public static void main(String[] args) {
        List<Spu> spuList = new ArrayList<>();
        Spu spu = new Spu();
        spu.setSpuCoverUrl(Collections.singletonList(new ProductMediaInfoModel()));
        spuList.add(spu);

        Map<String, Object> model = new HashMap<>();
        model.put("spuList", spuList);

        Optional<String> spuHtml = FreeMarkerUtils.getTplText("spuList.html", model);
        spuHtml.ifPresent(item -> {
            System.out.println(item);
            log.info(item);
        });
    }


    public static class Spu {
        private String spuTitle = "zhangsan de zi wo xiuynag";

        private String categoryName = "English";

        private Integer minAge = 9;

        private Integer maxAge = 16;

        private String extUrlInfo = "https://www.allschool.com/find?skuFirstTimeLeft=32400&skuFirstTimeRight=75600&ageList=3&categoryIds=";

        private List<ProductMediaInfoModel> spuCoverUrl;

        public String getSpuTitle() {
            return spuTitle;
        }

        public void setSpuTitle(String spuTitle) {
            this.spuTitle = spuTitle;
        }

        public String getCategoryName() {
            return categoryName;
        }

        public void setCategoryName(String categoryName) {
            this.categoryName = categoryName;
        }

        public Integer getMinAge() {
            return minAge;
        }

        public void setMinAge(Integer minAge) {
            this.minAge = minAge;
        }

        public Integer getMaxAge() {
            return maxAge;
        }

        public void setMaxAge(Integer maxAge) {
            this.maxAge = maxAge;
        }

        public String getExtUrlInfo() {
            return extUrlInfo;
        }

        public void setExtUrlInfo(String extUrlInfo) {
            this.extUrlInfo = extUrlInfo;
        }

        public List<ProductMediaInfoModel> getSpuCoverUrl() {
            return spuCoverUrl;
        }

        public void setSpuCoverUrl(List<ProductMediaInfoModel> spuCoverUrl) {
            this.spuCoverUrl = spuCoverUrl;
        }
    }


    public static class ProductMediaInfoModel {

        private Integer type = 1;

        private String data = "https://asset-01.allschoolcdn.com/teach/course-management/cover/16859b886e0491cb0c6967a61c387f385373651adeb49d72/Add%20a%20heading%20%2813%29.png?imageMogr2/format/webp/thumbnail/800x/sharpen/70";


        public Integer getType() {
            return type;
        }

        public void setType(Integer type) {
            this.type = type;
        }

        public String getData() {
            return data;
        }

        public void setData(String data) {
            this.data = data;
        }
    }

}
